define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'user/index',
        add_url: 'user/add',
        edit_url: 'user/edit',
        delete_url: 'user/delete',
        export_url: 'user/export',
        modify_url: 'user/modify',
        points_url:'points.log/index',
        order_url:'order/index'
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                toolbar:['refresh'/*,'add'*/,'delete'],
                cols: [[
                    {type: 'checkbox'},
                    {field: 'id', title: 'id'},
                    {field: 'nickname', title: '昵称'},
                    {field: 'portrait', title: '头像',templet: ea.table.image,search: false},
                    {field: 'phone', title: '账户(手机号)'},
                    {field: 'points', title: '积分',search: false},
                    // {field: 'openid', title: 'OPENID'},
                    // {field: 'unionid', title: 'UNIONID'},
                    /*{field: 'salt', title: '密码盐'},*/
                    {field: 'status', title: '状态', templet: ea.table.switch},
                    /*{field: 'is_updated', title: '是否更新微信信息 1:已更新 2:未更新'},*/
                    {field: 'create_time', title: '注册时间',search:'range'},
                    {width: 250, title: '操作',templet: ea.table.tool, operat: [
                            'edit',
                            [{
                                text: '积分详情',
                                url: init.points_url,
                                method: 'open',
                                fieldExtra: {'user_id': 'id'},
                                auth: '',
                                class: 'layui-btn layui-btn-xs layui-btn-danger',
                                extend: 'data-full="true"',
                            }],
                            [{
                                text: '消费记录',
                                url: init.order_url,
                                fieldExtra: {'user_id': 'id'},
                                method: 'open',
                                auth: 'images',
                                class: 'layui-btn layui-btn-xs layui-btn-normal',
                                extend: 'data-full="true"',
                            }],
                            'delete']},
                ]],
				done: function (){
                    $(".layui-table-body>table>tbody>tr").each(function (index, val) {
                        $($(".layui-table-fixed .layui-table-body table tr")[index]).height($(val).height());
                    });
                },
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
    };
    return Controller;
});